﻿package mortal.game.control
{
    import Message.Game.*;
    import Message.Public.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.proxy.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.player.info.*;
    import mortal.game.view.friend.*;
    import mortal.game.view.friend.data.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class FriendController extends Controller
    {
        private var _friendProxy:FriendProxy;
        private var _friendModule:FriendModule;

        public function FriendController()
        {
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._friendProxy = GameProxy.friend;
            return;
        }// end function

        override protected function initView() : IView
        {
            if (this._friendModule == null)
            {
                this._friendModule = new FriendModule();
                this._friendModule.addEventListener(WindowEvent.SHOW, this.onFriendShow);
                this._friendModule.addEventListener(WindowEvent.CLOSE, this.onFriendClose);
            }
            return this._friendModule;
        }// end function

        override protected function initServer() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.GetAllFriendRecords, this.getAllFriendRecordsHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendApplyRemind, this.friendApplyRemindHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendApplyReply, this.replyApplyerHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendUpdate, this.friendUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendInfoUpdate, this.friendInfoUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendApplyListUpdate, this.friendApplyListUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendOnlineStatus, this.FriendOnLineUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.FriendDelete, this.friendDeleteHandler);
            NetDispatcher.addCmdListener(ServerCommand.AddToRecent, this.addToRecentHandler);
            Dispatcher.addEventListener(EventName.FriendApply, this.friendApplyHandler);
            Dispatcher.addEventListener(EventName.FriendReply, this.friendReplyHandler);
            Dispatcher.addEventListener(EventName.SignatureUpdate, this.signUpdateHandler);
            Dispatcher.addEventListener(EventName.AddToBlackList, this.addToBlackListHandler);
            return;
        }// end function

        private function onFriendShow(event:Event) : void
        {
            NetDispatcher.addCmdListener(ServerCommand.GetOneKeyMakeFriendsInfo, this.oneKeyFriendHandler);
            NetDispatcher.addCmdListener(ServerCommand.GetRoleList, this.getRolesHandler);
            Dispatcher.addEventListener(EventName.FriendDeleteListReq, this.deleteListReqHandler);
            Dispatcher.addEventListener(EventName.FriendAddToDelete, this.addToDeleteListHandler);
            Dispatcher.addEventListener(EventName.FriendCancelDelete, this.cancelDeleteHandler);
            Dispatcher.addEventListener(EventName.FriendDelete, this.deleteFriendsHandler);
            Dispatcher.addEventListener(EventName.FriendSearch, this.searchFriendHandler);
            Dispatcher.addEventListener(EventName.FriendDeleteRecord, this.deleteRecordHandler);
            Dispatcher.addEventListener(EventName.ModifyFriendType, this.ModifyFriendTypeHandler);
            this._friendModule.updateSelfInfo(this.cache.role);
            return;
        }// end function

        private function onFriendClose(event:Event) : void
        {
            NetDispatcher.removeCmdListener(ServerCommand.GetOneKeyMakeFriendsInfo, this.oneKeyFriendHandler);
            NetDispatcher.removeCmdListener(ServerCommand.GetRoleList, this.getRolesHandler);
            Dispatcher.removeEventListener(EventName.FriendDeleteListReq, this.deleteListReqHandler);
            Dispatcher.removeEventListener(EventName.FriendAddToDelete, this.addToDeleteListHandler);
            Dispatcher.removeEventListener(EventName.FriendCancelDelete, this.cancelDeleteHandler);
            Dispatcher.removeEventListener(EventName.FriendDelete, this.deleteFriendsHandler);
            Dispatcher.removeEventListener(EventName.FriendSearch, this.searchFriendHandler);
            Dispatcher.removeEventListener(EventName.FriendDeleteRecord, this.deleteRecordHandler);
            Dispatcher.removeEventListener(EventName.ModifyFriendType, this.ModifyFriendTypeHandler);
            return;
        }// end function

        private function friendApplyHandler(event:DataEvent) : void
        {
            this._friendProxy.apply([event.data]);
            return;
        }// end function

        private function getFriendListHandler(param1:Object = null) : void
        {
            var _loc_4:SFriendRecord = null;
            var _loc_5:Array = null;
            var _loc_2:* = param1 as Array;
            var _loc_3:int = -1;
            for each (_loc_4 in _loc_2)
            {
                
                _loc_3 = _loc_3 < 0 ? (_loc_4.flag) : (_loc_3);
            }
            cache.friend.updateList(_loc_3, _loc_2);
            if (this._friendModule == null)
            {
                return;
            }
            this.setFriendsListDisplay();
            if (_loc_2.length != 0)
            {
                if (_loc_3 == EFriendFlag._EFriendFlagFriend)
                {
                    _loc_5 = cache.friend.getCloseFriendList();
                    this._friendModule.updateCloseList(_loc_5);
                    this.setFriendsListDisplay();
                }
                else if (_loc_3 == EFriendFlag._EFriendFlagBlackList)
                {
                }
                else
                {
                    this._friendModule.openList(2);
                }
                this._friendModule.updateCurrList();
            }
            else
            {
                this._friendModule.updateList(new Array());
                if (this._friendModule.currSelGroup == 0)
                {
                    this._friendModule.updateCloseList();
                    this._friendModule.updatePosition(1);
                }
            }
            return;
        }// end function

        private function friendApplyRemindHandler(param1:Object = null) : void
        {
            var _loc_2:SMiniPlayer = null;
            var _loc_3:Object = null;
            if (param1)
            {
                if (cache.friend.friendList.length >= GameConst.MaxFriendAmount)
                {
                    return;
                }
                _loc_2 = param1 as SMiniPlayer;
                if (ClientSetting.local.getIsDone(IsDoneType.RefuseOtherApply))
                {
                    _loc_3 = {};
                    _loc_3["result"] = EFriendReplyResult._EFriendReplyResultReject;
                    _loc_3["playerId"] = _loc_2.entityId.id;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FriendReply, _loc_3));
                }
                else
                {
                    if (FriendIcon.instance.isHide)
                    {
                        FriendIcon.instance.show();
                    }
                    cache.friend.updateApplyList(_loc_2, EUpdateType._EUpdateTypeAdd);
                }
            }
            return;
        }// end function

        private function friendReplyHandler(event:DataEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:Array = null;
            if (event.data)
            {
                _loc_2 = event.data.result as int;
                _loc_3 = event.data.playerId as Array;
                if (_loc_3)
                {
                    this._friendProxy.reply(_loc_3, _loc_2, 1);
                }
            }
            return;
        }// end function

        private function friendApplyListUpdateHandler(param1:Object) : void
        {
            var _loc_2:int = 0;
            var _loc_3:Array = null;
            if (param1)
            {
                _loc_2 = param1.replyType as int;
                _loc_3 = param1.ids as Array;
                cache.friend.updateApplyList(_loc_3, EUpdateType._EUpdateTypeDel);
                if (cache.friend.applyList.length == 0)
                {
                    FriendApplyWin.instance.hide();
                    FriendIcon.instance.hide();
                }
            }
            return;
        }// end function

        private function replyApplyerHandler(param1:Object = null) : void
        {
            var _loc_2:SFriendReplyMsg = null;
            var _loc_3:int = 0;
            var _loc_4:String = null;
            if (param1)
            {
                _loc_2 = param1 as SFriendReplyMsg;
                _loc_3 = Cache.instance.role.playerInfo.playerId;
                _loc_4 = "";
                if (_loc_3 == _loc_2.apply.entityId.id)
                {
                    _loc_4 = _loc_2.reply.name;
                }
                else
                {
                    _loc_4 = _loc_2.apply.name;
                }
                switch(_loc_2.result)
                {
                    case EFriendReplyResult._EFriendReplyResultAccept:
                    {
                        MsgManager.showRollTipsMsg(Language.getStringByParam(20399, _loc_4));
                        break;
                    }
                    case EFriendReplyResult._EFriendReplyResultReject:
                    {
                        MsgManager.showRollTipsMsg(Language.getString(20400));
                        break;
                    }
                    case EFriendReplyResult._EFriendReplyApplicantAmountLimit:
                    {
                        MsgManager.showRollTipsMsg(Language.getString(20401));
                        break;
                    }
                    case EFriendReplyResult._EFriendReplyReplierAmountLimit:
                    {
                        MsgManager.showRollTipsMsg(Language.getString(20402));
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return;
        }// end function

        private function oneKeyFriendHandler(param1:Object = null) : void
        {
            return;
        }// end function

        private function friendListReqHandler(event:DataEvent) : void
        {
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_2:* = event.data as int;
            var _loc_3:* = cache.friend.getCacheDataByGroup(_loc_2);
            if (!this._friendModule)
            {
                return;
            }
            if (_loc_3.length != 0)
            {
                if (_loc_2 == 0)
                {
                    _loc_4 = cache.friend.getCloseFriendList();
                    this._friendModule.updateCloseList(_loc_4);
                    this._friendModule.updatePosition(1);
                    this.setFriendsListDisplay();
                }
                else
                {
                    this._friendModule.openList(2);
                }
                this._friendModule.updateCurrList();
            }
            else
            {
                switch(_loc_2)
                {
                    case 0:
                    {
                        _loc_5 = EFriendFlag._EFriendFlagFriend;
                        break;
                    }
                    case 1:
                    {
                        _loc_5 = EFriendFlag._EFriendFlagEnemy;
                        break;
                    }
                    case 2:
                    {
                        _loc_5 = EFriendFlag._EFriendFlagBlackList;
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
                this._friendProxy.getFriendList(_loc_5);
            }
            return;
        }// end function

        private function setFriendsListDisplay() : void
        {
            this._friendModule.openList(0);
            this._friendModule.closeList(1);
            if (cache.friend.friendList.length == 0)
            {
                this._friendModule.updatePosition(0);
                this._friendModule.closeList(0);
            }
            else if (cache.friend.closeFriendList.length == 0)
            {
                this._friendModule.closeList(0);
                this._friendModule.openList(1);
            }
            this._friendModule.updatePosition(1);
            this._friendModule.updateRoleNum(0);
            this._friendModule.updateRoleNum(1);
            return;
        }// end function

        private function deleteListReqHandler(event:DataEvent) : void
        {
            var _loc_2:* = cache.friend.friendList;
            this._friendModule.friendDeletePanel.updateList(_loc_2);
            return;
        }// end function

        private function addToDeleteListHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SelectedCellRenderer;
            this._friendModule.friendDeletePanel.updateList(_loc_2);
            return;
        }// end function

        private function cancelDeleteHandler(event:DataEvent) : void
        {
            this._friendModule.friendDeletePanel.cancelDelete(event.data);
            return;
        }// end function

        private function deleteFriendsHandler(event:DataEvent) : void
        {
            var _loc_2:* = cache.friend.removeFriendByIds(event.data.ids as Array);
            if (event.data.type == 1)
            {
                this._friendModule.friendDeletePanel.updateList(cache.friend.friendList);
                this._friendModule.friendDeletePanel.clear();
            }
            this._friendModule.updateList(cache.friend.friendList);
            this._friendModule.updateRoleNum(1);
            if (_loc_2)
            {
                this._friendModule.updateCloseList();
                this._friendModule.updateRoleNum(0);
            }
            this._friendProxy.removeAll(EFriendFlag._EFriendFlagFriend, event.data.ids as Array);
            return;
        }// end function

        private function deleteRecordHandler(event:DataEvent) : void
        {
            var _loc_3:Number = NaN;
            var _loc_4:int = 0;
            var _loc_2:* = this._friendModule.currSelGroup;
            switch(_loc_2)
            {
                case 0:
                {
                    break;
                }
                case 1:
                {
                    break;
                }
                case 2:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            if (event.data is SMiniPlayer)
            {
            }
            return;
        }// end function

        private function addRecord(param1:SFriendRecord) : void
        {
            var _loc_2:SFriendRecord = null;
            var _loc_3:EntityInfo = null;
            for each (_loc_2 in cache.friend.blackList)
            {
                
                if (param1.friendPlayer.entityId.id == _loc_2.friendPlayer.entityId.id)
                {
                    cache.friend.removeRecordById(EFriendFlag._EFriendFlagBlackList, _loc_2.recordId);
                    if (!view.isHide && this._friendModule.currSelGroup == EFriendFlag._EFriendFlagBlackList)
                    {
                        this._friendModule.updateList(cache.friend.blackList);
                    }
                    break;
                }
            }
            cache.friend.addRecord(param1);
            _loc_3 = cache.entity.getEntityInfoById(param1.friendPlayer.entityId);
            if (_loc_3)
            {
                _loc_3.updateIsFriend();
            }
            if (param1.flag == EFriendFlag._EFriendFlagFriend && !view.isHide)
            {
                this._friendModule.updateRoleNum(1);
                if (this._friendModule.currSelGroup == 0)
                {
                    this.setFriendsListDisplay();
                }
            }
            if (!view.isHide)
            {
                this._friendModule.updateCurrList();
            }
            return;
        }// end function

        private function deleteRecord(param1:int, param2:Number) : void
        {
            var _loc_3:* = cache.friend.getRecordById(param1, param2);
            if (_loc_3 == null)
            {
                return;
            }
            cache.friend.removeRecordById(param1, param2);
            var _loc_4:* = cache.entity.getEntityInfoById(_loc_3.friendPlayer.entityId);
            if (_loc_4)
            {
                _loc_4.updateIsFriend();
            }
            if (this._friendModule == null)
            {
                return;
            }
            if (param1 == this._friendModule.currSelGroup)
            {
                this._friendModule.updateCurrList();
            }
            if (this._friendModule.currSelGroup == 0)
            {
                this._friendModule.updateCloseList();
                this._friendModule.updateRoleNum(0);
                this._friendModule.updateRoleNum(1);
                this._friendModule.updatePosition(1);
            }
            return;
        }// end function

        private function searchFriendHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Array;
            GameProxy.player.findMiniPlayerByName(_loc_2);
            return;
        }// end function

        private function friendUpdateHandler(param1:Object) : void
        {
            var _loc_2:SFriendRecordMsg = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (param1)
            {
                _loc_2 = param1 as SFriendRecordMsg;
                switch(_loc_2.type)
                {
                    case EUpdateType._EUpdateTypeAdd:
                    {
                        this.addRecord(_loc_2.friendRecord);
                        break;
                    }
                    case EUpdateType._EUpdateTypeDel:
                    {
                        _loc_3 = _loc_2.friendRecord.flag;
                        _loc_4 = 0;
                        switch(_loc_3)
                        {
                            case EFriendFlag._EFriendFlagFriend:
                            {
                                _loc_4 = 0;
                                break;
                            }
                            case EFriendFlag._EFriendFlagEnemy:
                            {
                                _loc_4 = 1;
                                break;
                            }
                            case EFriendFlag._EFriendFlagBlackList:
                            {
                                _loc_4 = 3;
                                break;
                            }
                            default:
                            {
                                break;
                            }
                        }
                        this.deleteRecord(_loc_4, _loc_2.friendRecord.recordId);
                        break;
                    }
                    case EUpdateType._EUpdateTypeUpdate:
                    {
                        cache.friend.updateRecordInfo(_loc_2.friendRecord);
                        if (this._friendModule)
                        {
                            this._friendModule.updateCurrList();
                        }
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return;
        }// end function

        private function friendDeleteHandler(param1:Object) : void
        {
            var _loc_2:SFriendRemoveMsg = null;
            var _loc_3:int = 0;
            var _loc_4:Array = null;
            if (param1)
            {
                if (this._friendModule == null)
                {
                    return;
                }
                _loc_2 = param1 as SFriendRemoveMsg;
                _loc_4 = cache.friend.getCacheDataByType(_loc_2.flag);
                cache.friend.removeRecordByRoleId(_loc_2.flag, _loc_2.fromPlayerId);
                this._friendModule.updateList(_loc_4);
                if (_loc_2.flag == EFriendFlag._EFriendFlagFriend)
                {
                    this._friendModule.updateCloseList();
                    this._friendModule.updateRoleNum(0);
                    this._friendModule.updateRoleNum(1);
                    this._friendModule.updatePosition(1);
                }
            }
            return;
        }// end function

        private function FriendOnLineUpdateHandler(param1:Object) : void
        {
            var _loc_2:SFriendInfoMsg = null;
            var _loc_3:SFriendRecord = null;
            var _loc_4:String = null;
            if (param1)
            {
                _loc_2 = param1 as SFriendInfoMsg;
                _loc_3 = cache.friend.findRecordByRoleId(_loc_2.fromPlayerId, _loc_2.flag);
                if (_loc_3)
                {
                    if (_loc_3.flag == EFriendFlag._EFriendFlagFriend)
                    {
                        _loc_4 = Language.getStringByParam(20403, _loc_3.friendPlayer.name);
                        if (_loc_2.online)
                        {
                            _loc_4 = _loc_4 + Language.getString(20404);
                        }
                        else
                        {
                            _loc_4 = _loc_4 + Language.getString(20405);
                        }
                        MsgManager.addTipText(_loc_4, MsgHistoryType.FriendMsg);
                    }
                }
                cache.friend.updateRecordInfo(_loc_2);
                if (!view.isHide)
                {
                    this._friendModule.updateCurrList();
                    if (_loc_2.flag == EFriendFlag._EFriendFlagFriend)
                    {
                        if (cache.friend.judgeCloseFriend(_loc_2.entityId.id))
                        {
                            this._friendModule.updateCloseList();
                            this._friendModule.updateRoleNum(0);
                        }
                        this._friendModule.updateRoleNum(1);
                    }
                }
            }
            return;
        }// end function

        private function signUpdateHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as String;
            Cache.instance.role.playerInfo.signature = _loc_2;
            GameProxy.player.sendSignature(_loc_2);
            return;
        }// end function

        private function addToBlackListHandler(event:DataEvent) : void
        {
            var _loc_2:Object = null;
            var _loc_3:SFriendRecord = null;
            if (event.data is SMiniPlayer)
            {
                _loc_2 = event.data as SMiniPlayer;
                _loc_3 = cache.friend.findRecordByRoleId(_loc_2.entityId.id);
                if (_loc_3)
                {
                    this.addToBlackList(_loc_3);
                }
                else
                {
                    this._friendProxy.addToBlackList(_loc_2.entityId.id);
                }
            }
            if (event.data is SFriendRecord)
            {
                _loc_2 = event.data as SFriendRecord;
                this.addToBlackList(_loc_2 as SFriendRecord);
            }
            this._friendProxy.getFriendList(EFriendFlag._EFriendFlagBlackList);
            return;
        }// end function

        private function addToBlackList(param1:SFriendRecord) : void
        {
            if (param1.flag != EFriendFlag._EFriendFlagFriend)
            {
                this._friendProxy.addToBlackList(param1.friendPlayer.entityId.id);
                return;
            }
            this._friendProxy.moveIntoList(param1.recordId, param1.flag, EFriendFlag._EFriendFlagBlackList);
            var _loc_2:int = 0;
            if (param1.flag == EFriendFlag._EFriendFlagFriend)
            {
                _loc_2 = 0;
            }
            else if (param1.flag == EFriendFlag._EFriendFlagEnemy)
            {
                _loc_2 = 1;
            }
            cache.friend.removeRecordById(_loc_2, param1.recordId);
            var _loc_3:* = cache.entity.getEntityInfoById(param1.friendPlayer.entityId);
            if (_loc_3)
            {
                _loc_3.updateIsFriend();
            }
            if (!this._friendModule.isHide)
            {
                this._friendModule.updateCurrList();
            }
            if (param1.flag == EFriendFlag._EFriendFlagFriend && !this._friendModule.isHide)
            {
                this._friendModule.updateRoleNum(1);
                if (param1.friendType == EFriendType._EFriendtypeIntimate)
                {
                    this._friendModule.updateCloseList();
                    this._friendModule.updateRoleNum(0);
                }
                this._friendModule.updatePosition(1);
            }
            return;
        }// end function

        private function getRolesHandler(param1:Object) : void
        {
            var _loc_2:Array = null;
            if (param1 && (param1 as Array).length != 0)
            {
                _loc_2 = param1 as Array;
                if (_loc_2.length > 0)
                {
                    this._friendModule.friendSetPanel.searchRole = _loc_2[0];
                    this._friendModule.friendSetPanel.updateData(_loc_2[0]);
                }
            }
            else
            {
                this._friendModule.friendSetPanel.updateData(null);
            }
            return;
        }// end function

        private function friendInfoUpdateHandler(param1:Object) : void
        {
            var _loc_2:SAttributeUpdate = null;
            var _loc_3:Object = null;
            if (param1)
            {
                _loc_2 = param1 as SAttributeUpdate;
                _loc_3 = {};
                _loc_3["attrId"] = _loc_2.attribute.value();
                _loc_3["value"] = _loc_2.valueStr;
                cache.friend.updateRecordById(_loc_2.value, _loc_3);
                if (this._friendModule == null)
                {
                    return;
                }
                this._friendModule.updateCurrList();
                if (cache.friend.judgeCloseFriend(_loc_2.value))
                {
                    this._friendModule.updateCloseList();
                }
            }
            return;
        }// end function

        private function ModifyFriendTypeHandler(event:DataEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_2:* = event.data as SFriendRecord;
            if (_loc_2.friendType == EFriendType._EFriendTypeNormal)
            {
                _loc_2.friendType = EFriendType._EFriendtypeIntimate;
                cache.friend.addCloseFriend(_loc_2);
                _loc_3 = EFriendType._EFriendTypeNormal;
                _loc_4 = EFriendType._EFriendtypeIntimate;
            }
            else
            {
                _loc_2.friendType = EFriendType._EFriendTypeNormal;
                cache.friend.removeCloseFriend(_loc_2.recordId);
                _loc_3 = EFriendType._EFriendtypeIntimate;
                _loc_4 = EFriendType._EFriendTypeNormal;
            }
            this._friendModule.updateCurrList();
            this._friendModule.updateCloseList();
            this._friendModule.updateRoleNum(0);
            this._friendModule.updatePosition(1);
            this._friendProxy.changeFriendType(_loc_2.recordId, _loc_3, _loc_4);
            return;
        }// end function

        private function getAllFriendRecordsHandler(param1:Object) : void
        {
            var _loc_3:EntityInfo = null;
            var _loc_4:SFriendRecord = null;
            var _loc_2:* = param1 as Array;
            if (_loc_2 != null)
            {
                for each (_loc_4 in _loc_2)
                {
                    
                    cache.friend.addRecord(_loc_4, false);
                    _loc_3 = cache.entity.getEntityInfoById(_loc_4.friendPlayer.entityId);
                    if (_loc_3)
                    {
                        _loc_3.updateIsFriend();
                    }
                }
            }
            cache.friend.friendSort(1);
            cache.friend.friendSort(2);
            return;
        }// end function

        private function addToRecentHandler(param1:Object) : void
        {
            var _loc_2:* = (param1 as Array)[0];
            if (_loc_2)
            {
                cache.friend.addToRecent(_loc_2);
            }
            return;
        }// end function

        private function recommendFriendHandler(param1:SeqOneKeyFriendsInfoMsg) : void
        {
            var _loc_2:Array = null;
            var _loc_3:SOneKeyFriendsInfo = null;
            var _loc_4:RoleInfoData = null;
            if (param1)
            {
                _loc_2 = [];
                for each (_loc_3 in param1.onkeyFriends)
                {
                    
                    _loc_4 = new RoleInfoData();
                    _loc_4.roleName = _loc_3.name;
                    _loc_4.roleSex = GameDefConfig.instance.getSex(_loc_3.sex).text;
                    _loc_4.roleLevel = _loc_3.level;
                    _loc_4.roleCombat = _loc_3.combat;
                    _loc_2.push(_loc_4);
                }
            }
            cache.friend.saveRecommendList(_loc_2);
            if (cache.friend.friendList.length < GameConst.MaxFriendAmount)
            {
                FriendRecommendIcon.instance.show();
            }
            return;
        }// end function

    }
}
